import { CHAPTER } from "@/api/config/servicePort";
import http from "@/api";

/**
 * @name 课程模块
 */

// 获取章节列表
export const getChapterListApi = (course_id: string, condition: any) => {
  return http.post<any[]>(CHAPTER + `/list`, { course_id: course_id, condition: condition });
};

export const addChapterApi = async (params: any) => {
  return http.post(CHAPTER + `/add`, params);
};

export const updateChapterApi = async (params: any) => {
  return http.post(CHAPTER + `/update`, params);
};

export const deleteChapterApi = async (params: any) => {
  return http.post(CHAPTER + `/delete`, params);
};

export const sortChapterApi = async (params: { data: { [chapter_id: number]: number }; course_id: number }) => {
  return http.post(CHAPTER + `/sort`, params);
};
